package com.sankuai.meituan;

import java.io.PrintWriter;
import java.io.StringWriter;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.ExceptionUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @program: mybatisUtil
 * @description:
 * @author: fengleifeng
 * @create: 2020-06-02 19:20
 **/
@SpringBootApplication
//@MapperScan("com.sankuai.meituan.cbc.loyalty.infrastructure.repository.mapper")
//@MapperScan("com.sankuai.meituan.cbc.loyalty.console.infrastructure.repository.mapper")
//@MapperScan("com.sankuai.meituan.cbc.product.dao.repository")
//@MapperScan("com.sankuai.meituan.cbc.apply.infrastructure.repository.mapper")
@Slf4j
public class SpringbootStater {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootStater.class, args);
//        log.error("[缓存刷新] refresh Cache Exception:{}", "123", new NullPointerException("null"));
//        System.out.println("-------------");
//        logFormatStrError(log,"[缓存刷新]  cacheName={} name={}  refresh Cache Exception={}",  new NullPointerException("null"),"1234","zzzz",getStackTrace(new NullPointerException("null")));
    }


    public static void logFormatStrError(Logger log, String formatStr, Throwable e, Object... args) {

        log.error(formatStr, args);
//        Cat.logError(e);
    }

    public static void logError(Logger log, String str, Throwable e) {
        log.error(str + " , error = {}", getStackTrace(e));
//        Cat.logError(e);
    }
    public static String getStackTrace(final Throwable throwable) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        throwable.printStackTrace(pw);
        return sw.getBuffer().toString();
    }
}
